var flag = 0;
$(".int").click(() => {
  //获取用户输入的信息
  let account = $("[name=account]").val(); //账号
  let pwd = $("[name=pwd]").val(); //密码
  let vcode = $("[name=vcode]").val().toLowerCase();//验证码
  // console.log(account,pwd,vcode); 检测是否取到值
  //获取后端数据
  $.ajax({
    url: "./mock/data.json",
  }).then((res) => {
    let data = res.results.login;
    console.log(data);
    for (let idx in data) {
      
      if (
        (data[idx].account == account ||
          data[idx].phone == account ||
          data[idx].email == account) &&
        data[idx].upwd == pwd &&
        data[idx].vcode.toLowerCase()==vcode
      ) {
        alert("恭喜您登录成功!");
        sessionStorage.setItem('username',data[idx].account);
        //登陆成功后跳转到首页
        setTimeout(() => {
        location.href ='./index.html'
        },1000)
        break;
      } else {

   if(idx == data.length - 1){
       flag++;
       alert('您输入的帐号、密码或验证码不对，请重新输入!');
if(flag > 3){
alert('您输入的次数已经超过三次，请明天再来!');
$("[name=account]").attr('disabled','disabled');
$("[name=pwd]").attr('disabled','disabled');
$("[name=vcode]").attr('disabled','disabled');
}
       
        $("[name=account]").val("");
        $("[name=pwd]").val("");
        $("[name=vcode]").val("");
        $("[name=account]").focus();
}else{

continue;//继续循环
}
      }
    }
  });
});
